#include <cstdlib>
#include <iostream>

#include "Instrument.h"
#include "Guitar.h"
#include "Printable.h"
#include "Table.h"

Instrument & createInstrument()
{
#ifndef NEW_G
    Guitar g;
    return g;
#else
    Guitar * pg = new Guitar();
    return (* pg);
#endif
}

void playMusic(const Instrument & in)
{
    in.play();
}

int main(int argc, char *argv[]) {
	std::cout << "Welcome to the QNX Momentics IDE" << std::endl;

	Guitar g;
	Guitar * pg2 = new Guitar;
	Instrument * pi2 = new Instrument;

	Instrument * pI1 = &g;
	Instrument & oI2 = g;

	pI1->play();
	oI2.play();

	std::cout << "temp obj test -->" << std::endl;
	playMusic(createInstrument());
    std::cout << "temp obj test <--" << std::endl;

	playMusic(Guitar());

	void (Instrument::* playproc)() const = &Instrument::play;

	(g.*playproc)();

	delete pi2;
	delete pg2;

	Printable<Guitar> prnguitar(g);
	prnguitar.Print();

	Table tbl("a table");
	Printable<Table> prntable(tbl);
	prntable.Print();

	return EXIT_SUCCESS;
}
